package xml;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.io.SAXReader;

public class Dom4JFileReader
{
	public Document readDocument(String path) throws DocumentException, IOException
	{
		if (path == null)
			throw new NullPointerException("readDocument: path must not be null");
		
		FileInputStream fis = null;
		try
		{
			SAXReader reader = new SAXReader();
			fis = new FileInputStream(path);
			Document doc = reader.read(fis);
			return (Document) doc.clone();
			
		}
		catch (FileNotFoundException e)
		{
			throw new FileNotFoundException("readDoc: File Not Found");
		}
		finally
		{
			fis.close();
		}
		
		
		
	}
	
}
